<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>汽车信息</title>
</head>
<style>
    a {
        text-underline: none;
        color: black;
    }
</style>
<body style="text-align: center;">
<jsp:include page="head.jsp"/>
<h1>汽车信息</h1>
<style>
    td a {
        text-decoration: none;
    }
</style>
<c:if test="${empty list}">
    <h2>还没有任何信息！</h2>
</c:if>
<c:if test="${not empty list}">
    <table style="margin: auto;">
        <tr>
            <th>序号</th>
            <th>id</th>
            <th>名字</th>
            <th>类型</th>
            <th>价格</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${list}" var="car" varStatus="x">
            <form action="" method="post">
                <tr>
                    <td><input type="text" value="${x.count } " readonly="readonly" disabled="disabled"></td>
                    <td><input type="text" value="${car.car_id}" readonly="readonly" disabled="disabled"></td>
                    <td><input type="text" value="${car.car_name}" readonly="readonly" disabled="disabled"></td>
                    <td><input type="text" value="${car.car_type}" readonly="readonly" disabled="disabled"></td>
                        <%--<td>${car.car_price}</td>--%>
                    <td>
                            <%--0表示任何一个数--%>
                        <input type="text"
                               value="<fmt:formatNumber type="number" value="${car.car_price}" pattern=".00"></fmt:formatNumber>"
                               readonly="readonly" disabled="disabled">
                    </td>
                    <td>
                        <a href="edit.jsp?index=${x.index}"/>
                        <input type="button" value="编辑">
                            <%-- <a href="edit.jsp?index=${x.index}">
                                    <input type="button" value="编辑">
                                 </a>
                            --%>

                            <%--
                            读取：${param[list.index].car_id};
                            --%>

                        <a href="delete?id=${car.car_id}" onclick="return confirm('确定删除?');"/>
                        <input type="button" value="删除">
                    </td>
                </tr>
            </form>
        </c:forEach>
        <tr>
            <td colspan="6">${bar}</td>
        </tr>
        <tr>
            <td colspan="6">
                <form action="showcar">
                    每页显示<input type="text" name="num" value="${num}">条
                    <input type="submit" value="确定">
                </form>
            </td>
        </tr>
    </table>
</c:if>
</body>
</html>